<%@page contentType="text/xml" pageEncoding="UTF-8"%><?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/gradebook/xml/timetable_teacher.xsl"?>
<%@page import="contents.entities.Timetable" %>
<%@page import="contents.entities.Teacher" %>
<%@page import="java.util.List" %>

<%
    Teacher teacher = (Teacher) request.getAttribute("teacher");
    List<Timetable> timetables = (List<Timetable>) request.getAttribute("timetables");
    int timetablesIndex = 0;
%>

<timetable xmlns="muf.sk/gradebook/timetable_teacher">
    <teacher><%=teacher.getFullName()%></teacher>
    
<%
    String dayTag;
    for (int day = 1; day <= 5; day++) {
        switch (day) {
            case 1: dayTag = "monday"; break;
            case 2: dayTag = "tuesday"; break;
            case 3: dayTag = "wednesday"; break;
            case 4: dayTag = "thursday"; break;
            default: dayTag = "friday"; break;
        }
%>
    
    <<%=dayTag%>>

<%
        for (int unit = 0; unit <= 9; unit++) {
            if (timetablesIndex < timetables.size() &&
                    timetables.get(timetablesIndex).getDay() == day && timetables.get(timetablesIndex).getTime() == unit) {
%>

        <lesson>
            <subject><%=timetables.get(timetablesIndex).getSubject().getFullName()%></subject>
            <class><%=timetables.get(timetablesIndex).getTimetableClass().getName()%></class>
        </lesson>

<%
                timetablesIndex++;
            } else {
%>

        <lesson />

<%
            
            }
        }
%>
        
    </<%=dayTag%>>
    
<%
    }
%>

</timetable>